<?php
$this->procSql(true);
$rs=$this->lastResult;
$pags=$this->totalPages;

$sql = "select SUM(MONTO) TOTAL from ($this->lastQuery) A";
$rsT = $this->db->queryToArray($sql);
$total = count($rsT) > 0 ? $rsT[0]["TOTAL"] : 0;
$total = isEmpty($total) ? 0 : $total;
?>
<div class="dttb">
<input type="hidden" name="page" id="page" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <caption>Paginas: <?php for ($i = 1; $i <= $pags; $i++) { ?>
        <a href="javascript:(function(){$('#page').val(<?php echo $i; ?>);doReportReq();})();">
            <?php echo " $i "; ?>&nbsp;-&nbsp;</a><?php } ?>
    </caption>
    <thead>
        <tr>
            <th scope="col">ESTUDIANTE/BENEF</th>
            <th scope="col">TIPO CTA.</th>
            <th scope="col">COBRO</th>
            <th scope="col">FECHA EMISION</th>
            <th scope="col">FECHA PAGO</th>        
            <th scope="col">FORMA PAGO</th>        
            <th scope="col">MONTOS</th>        
        </tr>
    </thead>
    <tbody>    
        <?php 
            foreach ($rs as $r) { ?>
                <tr>
                    <td><?php echo $r["FK_ESTUDIANTE"]." - ".getNombreCta($r["FK_ESTUDIANTE"], $r["tcuenta"], $this->db); ?></td>
                    <td><?php echo $r["tcuenta"] ?></td>
                    <td><?php echo $r["ID"] ?></td>
                    <td><?php echo date("d/m/Y", strtotime($r["fecha_emision"])) ?></td>
                    <td><?php echo date("d/m/Y", strtotime($r["fecha_pago"])) ?></td>
                    <td><?php echo $r["forma_pago"] ?></td>
                    <td><?php echo number_format($r["MONTO"], 2); ?></td>  
                </tr>
            <?php }
         ?>         
    </tbody>
    <tfoot>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <th>Total Cobrado</th>
            <th><?php echo number_format($total, 2); ?></th>
        </tr>
    </tfoot>
</table>
</div>